"""
@file:   user
@author: FrankYi
@date:   2020/08/13
@desc:
"""
from .base import db


class UserSouth(db.Model):
    __tablename__ = "user_south"
    userid = db.Column(db.Integer, primary_key=True, autoincrement=True)
    username = db.Column(db.String,nullable=True)
    useremail = db.Column(db.String,nullable=False)
    password = db.Column(db.String,nullable=False)
    comments = db.relationship('CommentSouth', backref='users')

    @classmethod
    def create_user(cls, username,useremail, password):
        user = cls()
        user.username = username
        user.useremail = useremail
        user.password = password
        db.session.add(user)
        db.session.commit()